package com.caine.ts.ch16;

import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.util.AttributeSet;
import android.view.MotionEvent;
import android.view.View;

import com.caine_ts.R;


public class DrawPaint extends View {
	
	private float currentX = 10.0f;
	private float currentY = 10.0f;
	Bitmap bit  = null;
	
public DrawPaint(Context context, AttributeSet attrs) {
		super(context, attrs);
		bit =  BitmapFactory.decodeResource(getResources(),R.drawable.plane);
		// TODO Auto-generated constructor stub
	}	

	@Override
	protected void onDraw(Canvas canvas) {
		// TODO Auto-generated method stub
		super.onDraw(canvas);
		Paint paint = new Paint();
		paint.setColor(Color.MAGENTA);
		//canvas.drawCircle(currentX, currentY, 15, paint);
		canvas.drawBitmap(bit, currentX, currentY, paint);
	}
	
	@Override
		public boolean onTouchEvent(MotionEvent event) {
			// TODO Auto-generated method stub
		    this.currentX = event.getX();
		    this.currentY = event.getY();
		    this.invalidate();
			return true;
		}
    
}
